#include "StdAfx.h"
#include "Rectangle.h"

CRectangle::CRectangle(void)
{
}

CRectangle::CRectangle(UINT type,CPoint pt)
{
	m_DrawType=type;
	Point=pt;
	PrePoint=pt;
	Height=80;
	Width=120;
	m_point1.x = pt.x - Width/2;
	m_point1.y = pt.y - Height/2;
	m_point2.x = pt.x;
	m_point2.y = pt.y - Height/2;
	m_point3.x = pt.x + Width/2;
	m_point3.y = pt.y - Height/2;
	m_point4.x = pt.x + Width/2;
	m_point4.y = pt.y;
	m_point5.x = pt.x + Width/2;
	m_point5.y = pt.y + Height/2;
	m_point6.x = pt.x;
	m_point6.y = pt.y + Height/2;
	m_point7.x = pt.x - Width/2;
	m_point7.y = pt.y + Height/2;
	m_point8.x = pt.x - Width/2;
	m_point8.y = pt.y;
}

void CRectangle::Draw(CDC *pDC)
{
	pDC->Rectangle(m_point1.x,m_point1.y,m_point5.x,m_point5.y);
}

void CRectangle::SetPoint(CPoint pt)
{
	Point=pt;
}

CPoint CRectangle::GetPoint()
{
	return Point;
}

UINT CRectangle::GetType()
{
	return m_DrawType;
}

void CRectangle::SetPrePoint(CPoint pt)
{
	PrePoint=pt;
}

CPoint CRectangle::GetPrePoint()
{
	return PrePoint;
}

void CRectangle::Move(CDC * pDC,CPoint pt)
{
	pDC->Rectangle(m_point1.x,m_point1.y,m_point5.x,m_point5.y);

	Point = Point + pt-PrePoint;
	m_point1 = m_point1 + pt - PrePoint;
	m_point2 = m_point2 + pt - PrePoint;
	m_point3 = m_point3 + pt - PrePoint;
	m_point4 = m_point4 + pt - PrePoint;	
	m_point5 = m_point5 + pt - PrePoint;
	m_point6 = m_point6 + pt - PrePoint;
	m_point7 = m_point7 + pt - PrePoint;
	m_point8 = m_point8 + pt - PrePoint;

	pDC->Rectangle(m_point1.x,m_point1.y,m_point5.x,m_point5.y);

	PrePoint = pt;
}


UINT CRectangle::GetHeight()
{
	return Height;
}
UINT CRectangle::GetWidth()
{
	return Width;
}

void CRectangle::SetWH()
{
	Width = m_point3.x - m_point1.x;
	Height = m_point7.y - m_point1.y;
}

void CRectangle::Resize(CDC *pDC,CPoint pt,int f)
{
	pDC->Rectangle(m_point1.x,m_point1.y,m_point5.x,m_point5.y);

	Change(pt,f);

	pDC->Rectangle(m_point1.x,m_point1.y,m_point5.x,m_point5.y);


}

CRectangle::~CRectangle(void)
{
}
